<template>
    <div>
        <h3>排房添加</h3>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>门店</td>
                    <td>
                        <select v-model="queryadd.ShopId">
                            <option value="">请选择</option>
                            <option :value="item.Id" v-for="item in shop.list">{{item.ShopName}}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>房型</td>
                    <td>
                        <select v-model="queryadd.HouseTypeId" @change="gethouseNolist">
                            <option value="">请选择</option>
                            <option :value="item.Id" v-for="item in house.list">{{item.HouseTypeName}}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>房号</td>
                    <td>
                        <select v-model="queryadd.HouseNoId">
                            <option value="">请选择</option>
                            <option :value="item.Id" v-for="item in data.houseNoList">{{item.HouseName}}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>姓名</td>
                    <td>
                        <input type="text" v-model="queryadd.UserName">
                    </td>
                </tr>
                <tr>
                    <td>身份证</td>
                    <td>
                        <input type="text" v-model="queryadd.Card" maxlength="18">
                    </td>
                </tr>
                <tr>
                    <td>手机号</td>
                    <td>
                        <input type="text" v-model="queryadd.Phone" maxlength="11">
                    </td>
                </tr>
                <tr>
                    <td>入住时间</td>
                    <td>
                        <input type="date" v-model="queryadd.BeginTime">
                    </td>
                </tr>
                <tr>
                    <td>离店时间</td>
                    <td>
                        <input type="date" v-model="queryadd.EndTime">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="排房" class="btn btn-primary" @click="ok">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import{ref,reactive,onMounted} from 'vue'
import {useRouter,useRoute} from 'vue-router'
import axios from 'axios';
import moment from 'moment';

import { useUserStore } from '@/stores/user';
import ShopList from '../Shop/ShopList.vue';
const UserStore=useUserStore();
const router=useRouter();
const route=useRoute();

onMounted(()=>{
    showshop();
    showHouse();
})
const data:any=reactive({
    shopList:[],
    houseTypeList:[],
    houseNoList:[]
    
})

const ok=()=>{
    axios({
        method:'post',
        url:'/api/House/HouseRowAdd',
        data:queryadd,
    })
    .then(res=>{
        console.log(res);
        if(res.data>0){
            alert("排房成功");
        }
        else{
            alert("排房失败");
        }
    })
    .catch(err=>{
        console.log(err);
    })
}
const gethouseNolist=()=>{
    axios({
        
        method:'get',
        url:'/api/House/GetHouseNoList',
        params:{
            pageSize:100,
            houseTypeId:queryadd.HouseTypeId,
            shopId:queryadd.ShopId,
        }
    })
    .then(res=>{
        console.log(res);
        data.houseNoList=res.data.list
    })
    .catch(err=>{
        console.log(err);
    })
}
//排房向后端传输数据
const queryadd:any=reactive({

  "ShopId": '',
  "HouseTypeId": '',
  "HouseNoId": '',
  "UserName": "",
  "Phone": "",
  "Card": "",
  "BeginTime": "",
  "EndTime": "",
})

const shop:any=reactive({
    list:[],
})
const showshop=()=>{
    axios({
        method:'get',
        url:'/api/Shop/GetShopList',
        params:{
            pageIndex:1,
            pageSize:1000,
        }
    })
    .then(res=>{
        console.log(res);
        shop.list=res.data.list     
    })
    .catch(err=>{
        console.log(err);
    })
}
const house:any=reactive({
    list:[],
})
const showHouse=()=>{
    axios({
        method:'get',
        url:'/api/House/GetHouseTypeList',
        params:{
            pageIndex:1,
            pageSize:1000,
        }   
    })
    .then(res=>{
        console.log(res);
        house.list=res.data.list
       
    })
    .catch(err=>{
        console.log(err);
    })
}




</script>

<style scoped>

</style>